<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>示例演示表单-FramkPHP</title>
<style type="text/css">
<!--
.formStyle{padding:20px;}
.formStyle ul{margin-bottom:10px;}
.formStyle input{width:260px;height:25px;border:solid 1px #ccc;}
#articleSubmit{display:block;width:100px;height:30px; line-height:30px; border:solid 1px #ccc; text-align:center;background-color:#eee; cursor:pointer;}
label.error {padding-left:10px;color:red;font-size:1.4em;font-family:"微软雅黑"; }

-->
</style> 
<?php $this->_show('head'); ?> 
<script type="text/javascript" src="<?php echo APP.'/View/js/validate.js';?>"></script>
<script type="text/javascript">

$().ready(function() {

   $("#articleForm").validate({
        rules: {
            title: { required:true,rangelength:[2,40]},
            content: {required:true,rangelength:[2,400]}
        },
        messages: {
            title: {required:"标题必填",rangelength:'标题请输入2-40个字符'},
			content: {required:"内容不能为空",rangelength:'内容输入2-400个字符'}
        } 
    });
	
	$('#articleSubmit').click(function(){
	 	if($("#articleForm").valid()){
			$("#articleForm").submit();
		}	
	 });
	
});

</script>
</head>
<body>
<?php $this->_show('header'); ?> 
<div class="container">
	<div class="mainBox">
		<!--tipDiv--->				
		<div class="tipDiv"><li id="alertMsg" class="alertTip"></li><li id="errorMsg" class="errorTip"></li></div>
	
		<!--formDiv--->
		<div class="formStyle">
		<?php if (!isset($one)){ ?>
			<form  method="post"  id="articleForm" action="<?php echo ACT.'/Article/add';?>">
				<ul>
					<p>文章标题</p>
					<p><input type="text" id="title"  name="title"/></p>
				</ul>	
				<ul>			
					<p>文章内容</p>
					<p><textarea id="content" name="content" cols="48" rows="6"></textarea></p>
				</ul>
				<ul class="subBtn">
					<a id="articleSubmit">提 交</a>
				</ul>	
			</form>
		<?php }else{ ?>
			<form  method="post"  id="articleForm" action="<?php echo ACT.'/Article/update';?>">
			<input type="hidden" id="id"  name="id" value="<?php echo $one['id']; ?>"/>
				<ul>
					<p>文章标题</p>
					<p><input type="text" id="title"  name="title"  value="<?php echo $one['title']; ?>"/></p>
				</ul>	
				<ul>			
					<p>文章内容</p>
					<p><textarea id="content" name="content" cols="48" rows="6"><?php echo $one['content']; ?></textarea></p>
				</ul>
				<ul>
					<a id="articleSubmit">提交保存</a>
				</ul>	
			</form>
		<?php } ?>
		</div>
	
	</div>
</div>
<!---container-->
<?php $this->_show('footer'); ?> 
</body>
</html>	 